package com.softserveinc.settings;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import com.softserveinc.data.BrowseSettings;

@SuppressWarnings("unused")
public class SettingsManager {

	private static final String TAG = SettingsManager.class.getSimpleName();

	private static final String FEEDBACK_TYPE = "feedback_type";

	private static final String DEFAULT_FEEDBACK_TYPE = "xml";

	private final Context context;

	private final BrowseSettings mainListSettings = new BrowseSettings();

	private String feedbackType;

	public SettingsManager(final Context context) {
		this.context = context;

		updateGlobalSettings();
	}

	public BrowseSettings getMainListSettings() {
		return mainListSettings;
	}

	public boolean updateGlobalSettings() {
		SharedPreferences preference = PreferenceManager
				.getDefaultSharedPreferences(context);

		String newFeedbackType = preference.getString(FEEDBACK_TYPE,
				DEFAULT_FEEDBACK_TYPE);

		boolean updateNeeded = false;

		if (newFeedbackType != feedbackType) {
			updateNeeded = true;
		}

		feedbackType = newFeedbackType;

		return updateNeeded;
	}

	public String getFeedbackType() {
		return feedbackType;
	}
}
